package com.mmx.service.impl;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.mmx.domain.entity.FlowHistory;
import com.mmx.mapper.FlowHistoryMapper;
import com.mmx.service.FlowHistoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @desc: 流程历史实现
 * @author: liushuai
 * @date: 2023/2/9 14:36
 */
@Service
public class FlowHistoryServiceImpl implements FlowHistoryService {

    @Resource
    private FlowHistoryMapper flowHistoryMapper;

    @Override
    public void insertFlowHistory(FlowHistory flowHistory) {
        if(ObjectUtil.isNull(flowHistory)){
           throw new IllegalArgumentException("流程历史不能为空");
        }
        if(StrUtil.isEmpty(flowHistory.getInstanceId())){
           throw new IllegalArgumentException("流程实例Id不能为空");
        }
        if(StrUtil.isEmpty(flowHistory.getNodeId())){
           throw new IllegalArgumentException("节点Id不能为空");
        }
        if(StrUtil.isEmpty(flowHistory.getNodeName())){
           throw new IllegalArgumentException("节点名称不能为空");
        }
        flowHistoryMapper.insertFlowHistory(flowHistory);

    }
}
